package com.ssis.graphics;

import java.io.IOException;
import java.util.HashMap;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;
import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader;

public class Textures {
	private static HashMap<String,Texture> images;

	private static String[] getTextureNames() {
		String[] s = {
				"cellsheet",
				"arcadepix_font_sheet",
				"hud_station_background",
				"hud_crew_background",
				"hud_station_buttons",
				"hud_crew_buttons",
				"logo",
				"starbig",
				"starmed",
				"starsml",
				"faces",
				"dialog_background",
				"station_cursor",
				"crew_cursor",
				"crew_assignments_cursor",
				"hud_crew_assignments"
		};
		return s;
	}
	
	public static void initialize() {
		try {
			images = new HashMap<String,Texture>();
			String[] names = getTextureNames();
			for(int i=0;i<names.length;i++) {
				images.put(names[i], TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/" + names[i] + ".png")));
			}
		} catch (IOException e) {
			Log.error("Image not found in textures.");
			e.printStackTrace();
		}
	}
	
	public static Texture getTexture(String name) {
		return images.get(name);
	}
}
